//
//  ZBViewController.m
//  ShareKitCNDemo
//
//  Created by  on 11-12-27.
//  Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
//

#import "ZBViewController.h"
#import "ShareEngine.h"
#import "ShareEditController.h"

@implementation ZBViewController

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"ShareKitCN";
	// Do any additional setup after loading the view, typically from a nib.
    _array =[[NSArray arrayWithObjects:SHARE_SINAWEIBO,
             SHARE_QQWEIBO,
             SHARE_RENREN,
             SHARE_NTESWEIBO,nil] retain];
}

-(void)dealloc {
    [_array release];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    [_array release];
    _array = nil;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *shareType =[_array objectAtIndex:indexPath.row];
    ShareEngine *engine =[[[ShareEngine alloc] initWithType:shareType] autorelease];
    ShareEditController *controller = [[[ShareEditController alloc] initWithEngine:engine] autorelease];
    [controller setText:@"分享测试" image:[UIImage imageNamed:@"demoImage.png"]];
    [self.navigationController pushViewController:controller animated:YES];    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [_array count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellID = @"cellID";
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell =     [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    cell.textLabel.text = [_array objectAtIndex:indexPath.row];
    return cell;
}

@end
